<template>
<div>
  <el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-width="100px">
    <el-form-item label="用户名" prop="userName">
      <el-col :span="8">
        <el-input ref="userName" v-model="loginForm.userName" placeholder="用户名">
        </el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="密码" prop="password">
      <el-col :span="8">
        <el-input ref="password" type="password" v-model="loginForm.password" placeholder="密码"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item>
      <el-col :span="8">
        <el-button @click="login">登录</el-button>
    </el-col>
  </el-form-item>
</el-form>
</div>
</template>

<script>
import { handlelogin } from '@/api/login'
export default {
  name: '',
  data () {
    return {
      loginForm: {
        userName: '',
        password: ''
      },
      res: '',
      passwordType: 'password',
      showDialog: 'false',
      loginRules: {
        userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
      }
    }
  },
  methods: {
    login () {
      console.log('userName' + this.loginForm.userName)
      console.log('password' + this.loginForm.password)
      handlelogin(this.loginForm).then(response => {
        var res = response.data
        console.log('****res123**' + response.data)
        if (res === true) {
          alert('登录成功')
          this.$router.push('/firstPage')
        } else {
          alert('用户名密码错误')
        }
        // console.log('****res123**' + response.data)
      })
      // console.log('qwe' + handlelogin(this.loginForm))
    }
  }
}
</script>

<style scoped>

</style>
